<extend name="public@base5"/>
<block name="main">
    <div class="wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link" href="{:url('Link/index')}">{:lang('ADMIN_LINK_INDEX')}</a>
            </li>
            <li class="nav-item d-none d-sm-inline-block">
                <a class="nav-link" href="{:url('Link/add')}">{:lang('ADMIN_LINK_ADD')}</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active">{:lang('ADMIN_LINK_EDIT')}</a>
            </li>
        </ul>
        <form method="put" class="js-ajax-form margin-top-20" action="admin/links/{$link.id}">
            <div class="row mb-3">
                <label for="input-link_name" class="col-sm-2 col-form-label text-sm-end">
                    <span class="form-required">*</span>{:lang('Name')}
                </label>
                <div class="col-md-8 col-sm-10">
                    <input type="text" class="form-control" id="input-link_name" name="name" value="{$link.name}">
                </div>
            </div>
            <div class="row mb-3">
                <label for="input-link_url" class="col-sm-2 col-form-label text-sm-end">
                    <span class="form-required">*</span>{:lang('Url')}
                </label>
                <div class="col-md-8 col-sm-10">
                    <input type="text" class="form-control" id="input-link_url" name="url" value="{$link.url}">
                </div>
            </div>
            <div class="row mb-3">
                <label for="input-image" class="col-sm-2 col-form-label text-sm-end">{:lang('Icon')}</label>
                <div class="col-md-8 col-sm-10">
                    <div class="input-group">
                        <input type="text" id="input-image" name="image" class="form-control" value="{$link.image}">
                        <span class="input-group-btn">
                            <a class="btn btn-primary"
                               href="javascript:uploadOneImage('{:lang('Upload Image')}','#input-image');">{:lang('Upload Image')}</a>
                        </span>
                    </div>
                </div>
            </div>
            <div class="row mb-3">
                <label for="input-target" class="col-sm-2 col-form-label text-sm-end">{:lang('Url Target')}</label>
                <div class="col-md-8 col-sm-10">
                    <select class="form-control" name="target" id="input-target">
                        <foreach name="targets" item="vo">
                            <php>$link_target_selected=$link['target']==$key?"selected='selected'":"";</php>
                            <option value="{$key}" {$link_target_selected}>{$vo}</option>
                        </foreach>
                    </select>
                </div>
            </div>
            <div class="row mb-3">
                <label for="input-link_description" class="col-sm-2 col-form-label text-sm-end">{:lang('Description')}</label>
                <div class="col-md-8 col-sm-10">
                <textarea class="form-control" name="description"
                          id="input-link_description">{$link.description}</textarea>
                </div>
            </div>
            <div class="row mb-3">
                <div class="offset-sm-2 col-sm-10">
                    <input type="hidden" name="id" value="{$link.id}">
                    <button type="submit" class="btn btn-primary js-ajax-submit">
                        <i class="fa fa-save fa-fw"></i> {:lang('SAVE')}
                    </button>
                    <a class="btn btn-secondary" href="{:url('Link/index')}">{:lang('BACK')}</a>
                </div>
            </div>
        </form>
    </div>
</block>
